package com.tj.seed.common.utils;

import javax.xml.bind.DatatypeConverter;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

public class SaltUtils {
    private static final int SALT_SIZE = 16;

    public static String salt() throws NoSuchAlgorithmException {
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        byte[] bytes = new byte[SALT_SIZE / 2];
        random.nextBytes(bytes);
        String salt = DatatypeConverter.printHexBinary(bytes);
        return salt;
    }
}
